package registnet.records.source;

import registnet.records.College;
import registnet.records.Department;

public class DepartmentSource {

	private String departmentCode;
	private Department department;
	
	
	
	/**
	 * Default constructor 
	 * 
	 * @param departmentCode - The code assigned to a department
	 */
	public DepartmentSource(String departmentCode){
		this.departmentCode = departmentCode;
		this.load();
	}
	
	
	/**
	 * Loads data from source 
	 */
	public void load(){
		try{
			registnet.dao.Unit DAOUnit = new registnet.dao.UnitPeer().getUnit(this.departmentCode);
			College college = new CollegeSource(DAOUnit.getCollege().getCollegeCode()).getCollege();
			this.department = new Department(this.departmentCode);
			this.department.setDepartmentName(DAOUnit.getUnitName());
			this.department.setCollege(college);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	
	/**
	 * Gets the department
	 * 
	 * @return	The department
	 */
	public Department getDepartment(){
		return this.department;
	}
}
